-module(ranks).
-export([fetch_title_and_rank/1]).
	
-define(GOOGLE_URL,
		"http://www.gdddddddddddddoogle.co.uk/search?q=").
	
% call inets:start() to initialize the http module
fetch_title_and_rank(Query) ->
	io:format("Query: ~p~n", [Query]),
	Url = google_url(Query),
	io:format("Url: ~s~n", [Url]),
	% handling multiple cases of a function return value
	case http:request(Url) of
		{ok, _} ->
			io:format("Success");
		{error, _} ->
			io:format("Failure")
	end,
	%{ok, {_, _, Body}} = http:request(Url),
	%io:format([Status]),
	%io:format([Headers]),
	%io:format([Body]),
	io:format("end").
	
google_url(Query) ->
	?GOOGLE_URL ++ Query.
		
